package net.chenlin.dp.modules.business.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import net.chenlin.dp.common.entity.Page;
import net.chenlin.dp.common.entity.R;
import net.chenlin.dp.modules.business.entity.dto.TestDto;
import net.chenlin.dp.modules.business.entity.vo.testManage.AppTestListVo;
import net.chenlin.dp.modules.business.entity.vo.testManage.TestManageVo;
import net.chenlin.dp.modules.business.service.TestManageService;
import net.chenlin.dp.modules.sys.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author Yangsm
 * @ClassName: TestManageController
 * @Description: TODO
 * @date 2022年10月18日 10:30
 */
@Slf4j
@RestController
@RequestMapping("/testManage")
@Api(tags = "试验管理")
public class TestManageController extends AbstractController {

    @Autowired
    private TestManageService testManageService;

    @RequestMapping(value = "/getUnderwayTestList", method = RequestMethod.POST)
    @ApiOperation(value = "展示正在进行的实验列表")
    public Page<TestManageVo> getUnderwayTestList(@RequestBody Map<String, Object> params) {
        return testManageService.getUnderwayTestList(params);
    }

    @RequestMapping(value = "/appTestList", method = RequestMethod.POST)
    @ApiOperation(value = "APP展示实验列表")
    public Page<AppTestListVo> appTestList(@RequestBody Map<String, Object> params) {
        return testManageService.appTestList(params);
    }

    @RequestMapping(value = "/stopTest", method = RequestMethod.GET)
    @ApiOperation(value = "终止正在进行的实验")
    public R stopTest(Long id) {
        return testManageService.stopTest(id);
    }

    @RequestMapping(value = "/creatTest", method = RequestMethod.POST)
    @ApiOperation(value = "创建试验")
    public R creatTest(@RequestBody TestDto dto) {
        //SysUserEntity user = getUser();
        //dto.setCreatId(user.getUserId());
        dto.setCreatId(1L);
        return testManageService.creatTest(dto);
    }

    @RequestMapping(value = "/newCreatTest", method = RequestMethod.POST)
    @ApiOperation(value = "新版本的创建试验")
    public R newCreatTest(@RequestBody TestDto dto) {
        //SysUserEntity user = getUser();
        //dto.setCreatId(user.getUserId());
        dto.setCreatId(1L);
        return testManageService.newCreatTest(dto);
    }

    @RequestMapping(value = "/editTest", method = RequestMethod.POST)
    @ApiOperation(value = "编辑试验")
    public R editTest(@RequestBody TestDto dto) {
        //SysUserEntity user = getUser();
        //dto.setCreatId(user.getUserId());
        dto.setCreatId(1L);
        return testManageService.editTest(dto);
    }

    @RequestMapping(value = "/getTestInfo", method = RequestMethod.GET)
    @ApiOperation(value = "根据试验编码查看试验信息")
    public R getTestInfo(String testNo) {
        return testManageService.getTestInfo(testNo);
    }

    @RequestMapping(value = "/deleteTestInfo", method = RequestMethod.GET)
    @ApiOperation(value = "根据试验编码查看试验信息")
    public R deleteTestInfo(String testNo) {
        return testManageService.deleteTestInfo(testNo);
    }


//    @RequestMapping(value = "/getTestList", method = RequestMethod.GET)
//    @ApiOperation(value = "获取实验编号")
//    public R getTestList() {
//        return testManageService.getTestList();
//    }
//
//    @RequestMapping(value = "/getDeviceList", method = RequestMethod.GET)
//    @ApiOperation(value = "获取设备编号")
//    public R getDeviceList(String no) {
//        return testManageService.getDeviceList(no);
//    }
//
//    @RequestMapping(value = "/getPassList", method = RequestMethod.GET)
//    @ApiOperation(value = "获取通道编号")
//    public R getPassList(String no) {
//        return testManageService.getPassList(no);
//    }
}
